<template>
    <div>
        <header-btn style="margin-bottom:10px" :btnList='listData' :tabIndex='tabIndex' @changetabIndex='tabIndexChange'>
            <el-select @change='changeWarehouse' style="width:150px;margin:17px 10px 0 0" size='medium'  v-model="wh_id" placeholder="请选择" >
                <el-option   v-for="item in myWarehouse"  :key="item.wh_id"  :label="item.wh_name" :value="item.wh_id"></el-option>
            </el-select>
        </header-btn>
        <assets-vue :whId='wh_id' ref="assetsVue" v-if="tabIndex==0"></assets-vue>
        <meterial-vue :whId='wh_id' ref="meterialVue" v-if="tabIndex==1"></meterial-vue>
    </div>
</template>

<script>
/* eslint-disable */ 
import headerBtn from "@/components/headerBtn"
import assetsVue from "./components/assets"
import meterialVue from "./components/meterial"
export default {
    name:"deptReporting",
    components:{ headerBtn,assetsVue,meterialVue},
    data(){
        return {
            wh_id:'',
            myWarehouse:[],
            listData:[
               {num:'',content:'资产报表'},
			   {num:'',content:'耗材报表'}
			],
            tabIndex:0,
        }
    },
    created(){
        this.tabIndex = Number(localStorage.curTabIndex||0)
        this.myWarehouse = this.$store.state.myWarehouse
        this.wh_id = this.$store.state.warehouseOfAssetsManager||this.$store.state.myWarehouse[0].wh_id
        // this.getData()
    },
    methods:{
        /**模块切换 */
        tabIndexChange(index){
            localStorage.curTabIndex = index
            this.tabIndex = index
            // this.getData()
        },
        getData(){
            this.$nextTick(()=>{
                if(this.tabIndex==0){
                    this.$refs.assetsVue.getData(this.wh_id)
                }else{
                    this.$refs.meterialVue.getData(this.wh_id)
                }
            })
        },
        /**当仓库值改变时，缓存起来,并刷新模块内数据 */
        changeWarehouse(val){
            this.getData()
        },

    }
}
</script>

<style lang='stylus' scoped>
</style>
